/*
 * @Autor: dingxiaolin
 * @Date: 2021-02-22 20:13:24
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-11-16 14:51:32
 */
const path = require('path');

function resolve(dir) {
    return path.join(__dirname, dir);
}
module.exports = {
    lintOnSave: false,
    publicPath: './',//码云用的二级目录，所以这里要用相对路径保证静态资源的访问
    outputDir: 'dist',
    filenameHashing: true,
    devServer: {
        host: '0.0.0.0',
        port: 8080,
        proxy: {
            '/api': {
                target: 'http://3743t536o7.wicp.vip/', // 新
                changeOrigin: true,
                secure: true,
                pathRewrite: {
                    '^/api': '/api/'
                }
            }
        }
    },
    chainWebpack: config => {
        config.resolve.alias
            .set('@', resolve('src'))
            .set('src', resolve('src'))
            .set('common', resolve('src/common'))
            .set('components', resolve('src/components'))
            .set('jquery', resolve('jquery'));
    },
    css: {
        loaderOptions: {
            sass: {
                prependData: `@import "@/style/variables.scss";`
            },
            postcss: {
                plugins: [
                    require('postcss-pxtorem')({ // 把px单位换算成rem单位
                        rootValue: 192, // 换算的基数(设计图750的根字体为75)
                        // selectorBlackList: ['weui', 'mu'], // 忽略转换正则匹配项
                        propList: ['*']
                    })
                ]
            }
        }
    },
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            // 为生产环境修改配置...
        } else {
            // 为开发环境修改配置...
        }
    }
};